<template>
  <div class="flex items-center justify-between p-10 bg-[#f5f6fa] rounded-6 mb-12">
    <div class="pr-8">
      <span class="text-13 c-[#000] ">{{leftText}}</span>
      <span class="c-[#f00]" v-if="is_required === 1">*</span>
    </div>
    <div class="flex items-center white-space" @click="toDetail">
      <span class="text-13 c-[#999]">{{rightText}}</span>
      <Right width="12" class="relative top--1" color="#999" />
    </div>
  </div>
</template>

<script setup>
import { defineProps, defineEmits } from 'vue'
import { Right } from '@nutui/icons-vue';
import { useRoute, useRouter } from 'vue-router'
import { useVisaStore } from '~/src/store/modules/visa';
const route = useRoute()
const router = useRouter()
defineEmits(['toDetail'])
const props = defineProps({
  leftText: {
    type: String,
    default: ''
  },
  material: {
    type: Object,
    default: {}
  },
  is_required: {
    type: Number,
  },
  uploadOrViewType: {
    type: Number,
    default: 1 // 1是上传文件，2是查看要求
  },
  rightText: {
    type: String,
    default: '待上传'
  }
})
const toDetail = () => {
  if (props.uploadOrViewType === 1) {
    console.log('%c [ props.material ]-46', 'font-size:13px; background:#8e0655; color:#d24a99;', props.material)

    let material = props.material
    let _material = {}
    for (const key in material) {
      _material[key] = material[key]
    }
    if (_material.type === 'application') {
      _material.material_id = 'application'
      _material.material_name = _material.application_name || 'application_name' //application_name  template photo_name idphoto
    } else if (_material.type === 'idphoto') {
      _material.material_id = 'idphoto'
      _material.material_name = _material.idphoto || 'idphoto' //application_name  template photo_name idphoto
    }
    useVisaStore().setUploadInfo(_material)
    // return
    router.push({ path: '/uploadFileDetail' })
  } else if (props.uploadOrViewType === 2) {
    useVisaStore().setNeedList(props.material)
    router.push({ path: '/viewNeed' })
  }
}
</script>

<style lang="scss" scoped>
</style>